package center.leon.zoofeign.controller;

import center.leon.zoocommon.common.Response;
import center.leon.zoocommon.holder.DynamicValueHolder;
import center.leon.zoofeignapi.dto.Monkey;
import center.leon.zoofeignapi.service.ZooMonkeyServiceApi;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author : Leon on XXM Mac
 * @since : create in 2024/8/19 11:14
 */
@Slf4j
@RestController
@RequestMapping(value = "/hello")
public class HelloController {

    @Resource
    private DynamicValueHolder dynamicValueHolder;
    @Resource
    private ZooMonkeyServiceApi zooMonkeyServiceApi;

    @GetMapping(value = "/world")
    public Response hello() {
        log.info("HelloController#Get#Hello#world : {}", dynamicValueHolder.getValue());
        return Response.success("HelloController#Get#Hello#world : ".concat(dynamicValueHolder.getValue()));
    }


    @GetMapping(value = "/monkey")
    public Response monkey() {
        Response<Monkey> monkeyResponse = zooMonkeyServiceApi.getMonkeyById(123L);
        log.info("HelloController#Get#Hello#monkey : {}", JSON.toJSONString(monkeyResponse.getData()));
        return Response.success(monkeyResponse.getData());
    }
}
